﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:System="clr-namespace:System;assembly=mscorlib"
                    xmlns:Behaviours="clr-namespace:MahApps.Metro.Behaviours"
                    xmlns:mm="http://metro.mahapps.com/winfx/xaml/controls"
                    xmlns:mmm="http://metro.mahapps.com/winfx/xaml/shared"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

  <FontFamily x:Key="HeaderFontFamily">Segoe UI Light, Lucida Sans Unicode, Verdana</FontFamily>
  <System:Double x:Key="WindowTitleFontSize">16</System:Double>
    <mmm:ToUpperConverter x:Key="ToUpperConverter" />

  <Style x:Key="MetroWindowButtonStyle"
         TargetType="{x:Type Button}">
    <Setter Property="FocusVisualStyle"
            Value="{x:Null}" />
    <Setter Property="IsTabStop"
            Value="False" />
    <Setter Property="Width"
            Value="34" />
    <Setter Property="MaxHeight"
            Value="34" />
    <Setter Property="Padding"
            Value="0" />
    <Setter Property="Template">
      <Setter.Value>       
        <ControlTemplate TargetType="{x:Type Button}">
          <Grid Background="#01FFFFFF">
          <ContentPresenter x:Name="contentPresenter" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"  SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" RecognizesAccessKey="True"   Opacity="0.75" />
        </Grid>
          <ControlTemplate.Triggers>
            <Trigger Property="IsMouseOver"   Value="True">
              <Setter TargetName="contentPresenter"  Property="Opacity"        Value="1" />
            </Trigger>
            <Trigger Property="IsMouseOver"   Value="False">
              <Setter TargetName="contentPresenter" Property="Opacity"    Value=".5" />
            </Trigger>            
          </ControlTemplate.Triggers>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
  </Style>

  <Style TargetType="{x:Type mm:MetroWindow}">    
    <Setter Property="TextElement.FontSize"            Value="{DynamicResource ContentFontSize}" />
    <Setter Property="WindowMinButtonStyle"            Value="{DynamicResource MetroWindowButtonStyle}" />
    <Setter Property="WindowMaxButtonStyle"            Value="{DynamicResource MetroWindowButtonStyle}" />
    <Setter Property="WindowCloseButtonStyle"            Value="{DynamicResource MetroWindowButtonStyle}" />
    <Setter Property="mmm:StylizedBehaviors.Behaviors">
      <Setter.Value>
        <mmm:StylizedBehaviorCollection>
          <mmm:BorderlessWindowBehavior />
          <mmm:WindowsSettingBehaviour />
          <mmm:GlowWindowBehavior />
        </mmm:StylizedBehaviorCollection>
      </Setter.Value>
    </Setter>
    <Setter Property="TitleForeground"            Value="{DynamicResource TextBrush}" />
    <Setter Property="Template"            Value="{StaticResource WindowTemplateKey}" />
    <Setter Property="TitleTemplate">
      <Setter.Value>
        <DataTemplate>
          <TextBlock Text="{TemplateBinding Content}"  TextTrimming="CharacterEllipsis" VerticalAlignment="Center" Margin="8 -1 0 0"  FontSize="{DynamicResource WindowTitleFontSize}"   FontFamily="{DynamicResource HeaderFontFamily}" />
        </DataTemplate>
      </Setter.Value>
    </Setter>
    <Style.Triggers>
      <DataTrigger Binding="{Binding RelativeSource={RelativeSource Self}, Path=TitleCaps, Mode=OneWay, Converter={StaticResource ToUpperConverter}}" Value="True">
        <Setter Property="TitleTemplate">
          <Setter.Value>
            <DataTemplate>
              <TextBlock Text="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Content, Converter={StaticResource ToUpperConverter}}" TextTrimming="CharacterEllipsis" VerticalAlignment="Center" Margin="8 -1 0 0" FontSize="{DynamicResource WindowTitleFontSize}" FontFamily="{DynamicResource HeaderFontFamily}" />
            </DataTemplate>
          </Setter.Value>
        </Setter>
      </DataTrigger>
      <DataTrigger Binding="{Binding RelativeSource={RelativeSource Self}, Path=Icon, Mode=OneWay, Converter={x:Static mmm:IsNullConverter.Instance}}" Value="False">
        <Setter Property="IconTemplate">
          <Setter.Value>
            <DataTemplate>
              <Image Width="{TemplateBinding Width}"  Height="{TemplateBinding Height}" Source="{TemplateBinding Content}" RenderOptions.EdgeMode="{Binding IconEdgeMode, Mode=OneWay, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type mm:MetroWindow}}}" RenderOptions.BitmapScalingMode="{Binding IconBitmapScalingMode, Mode=OneWay, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type mm:MetroWindow}}}" />
            </DataTemplate>
          </Setter.Value>
        </Setter>
      </DataTrigger>
    </Style.Triggers>
  </Style>
</ResourceDictionary>